<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticable;
use Illuminate\Database\Eloquent\Factories\HasFactory;


class User extends Authenticable
{
    use HasFactory;

    protected $fillable = ['email', 'user_name', 'password'];

    protected $with = ['profile'];

    public function profile()
    {
        return $this->hasOne(UserProfile::class, 'user_id');
    }

    public function skills()
    {
        return $this->hasMany(UserSkill::class, 'user_id');
    }

    public function teams()
    {
        return $this->belongsToMany(Team::class);
    }

    public function chatMessages()
    {
        return $this->hasMany(ChatMessage::class, 'user_id');
    }

    public function domainRoles()
    {
        return $this->belongsToMany(DomainRole::class, 'domain_role_user', 'user_id', 'role_id');
    }

    public function teamRoles()
    {
        return $this->belongsToMany(TeamRole::class, 'team_role_user', 'user_id', 'role_id');
    }
}
